﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	留言页面
'	2012.4.5

Sub main
	'留言配置
	If wapGuest<>"1" And wapGuest<>"0" Then wapGuest="1"'留言审核显示

	Dim p,act,rs,userid,name,sql,id,body_
	Dim num,num1,title,text,lianxi,agent
	Dim PageSize,count,page,i,pagecount
	id=getN("id",1)
	p=getN("p",1)
	if p<1 then p=1
	userid=user_array(0)
	act=request.QueryString("act")
	hu.title = "客服留言"
	body_ = checkMsg()'信息
	body_ = body_ & "[div=nav]-" & hu.url("?aid=index", "首页") & "-"
	if act="view" then
		set rs=hu.conn("select name,agent,title,HU_time,text,retext,retime from 74hu_guest where id=" & id)
		body_ = body_ & hu.url("guest.asp", "客服") & "-查看留言[/div]"
		if rs.EOF then
			body_ = body_ & "无此留言！<br/>"
		else
			name=nowml(rs("name"))
			id=rs("agent")
			If id<>"" And IsNumeric(id) Then name= hu.url("bbs_user.asp?id="&id, name)
			body_ = body_ & "标题："&nowml(rs("title"))&"<br/>作者："&name&"<br/>时间：" & fordate(rs("HU_time")) & "<br/>----------<br/>"&nowml(rs("text"))&"<br/>"
			if rs("retext")<>"" then body_ = body_ & "----------<br/>回复："&nowml(rs("retext"))&"<br/>时间："&fordate(rs("retime"))&"<br/>"
		end if
	elseif act="add" then
		num=getCheckCode
		body_ = body_ & hu.url("guest.asp", "客服") & "-发表留言[/div]"
		Dim formArray(6)
		formarray(0) = http_path&"guest.asp?act=save||post||提交留言"
		If userid=0 Then
			formarray(0) = formarray(0) & "||昵称：<br/>"
			formarray(1) = "input||name$$$$15$$20||<br/>标题：<br/>"
		Else
			formarray(0) = formarray(0) & "||标题：<br/>"
			formarray(1) = " "
		End If
		formarray(2) = "input||title$$$$20$$20||<br/>内容：<br/>"
		formarray(3) = "area||text$$$$20$$200||<br/>联系方式(不公开)：<br/>"
		formarray(4) = "input||lianxi$$$$20$$20||<br/>验证码："&num&"<br/>"
		formarray(5) = "input||num$$$$20$$10||<br/>"
		formarray(6) = "hidden||act$$save||num1$$"&numEncode(num)&"||"&bbsSid&"$$"&sid&"||"
		body_ = body_ & hu.getForm(formarray)
	elseif act="save" then
		num=getData("num")
		num1=numDecode(getData("num1"))
		if num<>num1 then rupt "错误", "验证码错误,请返回重试！"
		name=getD("name","")
		If userid<>0 Then name=user_array(1)'取当前用户名
		title=getD("title","")
		text=getD("text","")
		lianxi=getD("lianxi","")
		if name="" or title="" or text="" then rupt "错误", "昵称或标题、内容不能为空！"
		If userid<>0 Then
			agent=userid
		Else
			agent=user_ip
		End If
		if 0<hu.conn("select count(id) from 74hu_guest where title='"&title&"' and text='"&text&"'")(0) then rupt "错误", "请不要重复留言！"
		hu.conn("insert into 74hu_guest ([name],[title],[text],[hu_time],[lianxi],[agent],[retext]) values('"&name&"','"&title&"','"&text&"','"&time_now&"','"&lianxi&"','"&agent&"','')")
		hu.AutoRedirect = ""&http_path&"guest.asp?"&sid_str&""
		body_ = body_ & hu.url("guest.asp", "客服") & "-发表留言[/div]发表成功！"
		if wapGuest =1  then body_ = body_ & "发表的留言需要审核后显示"
	else
		body_ = body_ & "客服首页[/div]"
		if wapGuest =1  then body_ = body_ & "[div=tip]注:新留言审核后显示[/div]"
		sql = "select * from 74hu_guest order by id desc"
		If wapGuest=1 Then
			sql = "select * from 74hu_guest where retext<>'' order by id desc"
		End If
		Set rs = Server.CreateObject("ADODB.Recordset")
		rs.open sql, hu.db, 1, 1
		If Not rs.eof Then
			count = rs.recordcount
			PageSize=10
			page=getN("page",1)
			page=int(page)
			if page<=0 or page="" then page=1
			pagecount=(count+pagesize-1)\pagesize
			if page>pagecount then page=pagecount
			rs.move(pagesize*(page-1))
			body_ = body_ & "共("&count&")条" &hu.url("guest.asp?act=add","留言")&"<br/>"
			For i=1 To PageSize
				If rs.eof Then Exit For
				body_ = body_ & "[div=odd]" & hu.url("guest.asp?act=view&amp;id="&rs("ID")&"&amp;p="&p,i+(page-1)*PageSize&"."&nowml(rs("title")))&"[/div]"
				id = rs("agent")
				If IsNumeric(id) Then
					body_ = body_ & "[div=even][会员:<a href="""&http_path&"bbs_user.asp?id="&id&"&amp;"&sid_str&""">"&nowml(rs("name"))&"</a>"
				Else
					body_ = body_ & "[div=even][网友:"&nowml(rs("name"))
				End If
				if rs("retext")<>"" then
					body_ = body_ & "/已回"
				else
					body_ = body_ & "/未回"
				end if
				body_ = body_ & "][/div]"
				rs.moveNext
			Next
			body_ = body_ & showPage("guest.asp", "", page, pagecount) &""
		Else
			body_ = body_ & "还没有留言！<br/>"
		end if
		rs.close
		set rs=nothing
		body_ = body_ &showImg("post") &hu.url("guest.asp?act=add", "我要发表留言") & "<br/>"
	end if
	hu.body = comUbb(body_)
End Sub

%>